- plot()
- ggplot()
- Bonus: magick()
05/01/2020
Generic syntax: Plot(x,y…)
A more advanced syntax is: plot(x, y, type, main, sub, xlab, ylab)
where…
Type:
“p”: points
“l”: lines
“b”: both point and lines in a single place
“c”: join empty point by the lines
“o”: both lines and over-plotted point
“h”: histogram “s”: stair steps
“n”: no plotting
“xlab”: x-axis legends
“ylab”: y-axis legends
Exam grades of 10 students in two courses, X and Y, respectively
X = 40, 15, 50, 12, 22, 29, 21, 35, 14, 15
Y = 41, 42, 32, 14, 42, 27, 13, 50, 33, 22
X = c(40, 15, 50, 12, 22, 29, 21, 35, 14, 15) plot(X ,type = "l")
Y = c(41, 42, 32, 14, 42, 27, 13, 50, 33, 22) plot(Y ,type = "p")
Source: Kumar, 2020
Package: nCov2019
By: Dr. Guangchuang Yu (Southern Medical University)
remotes::install_github("GuangchuangYu/nCov2019")
Assign x and y
x <- get_nCov2019() y <- load_nCov2019()
Check results for x and y
x China (total confirmed cases): 95901 last update: 2020-12-21 20:45:32
y nCov2019 historical data last update: 2020-11-26
x['global']
name confirm suspect dead deadRate showRate heal 1 China 95901 7 4771 4.97 FALSE 89480 2 United States 18277433 0 324898 1.78 FALSE 10622096 3 India 10055560 0 145810 1.45 FALSE 9606111 4 Brazil 7238600 0 186764 2.58 FALSE 6409986 5 Russia 2850042 0 50723 1.78 FALSE 2273510 6 France 2529756 0 60665 2.4 FALSE 189638 7 United Kingdom 2079564 0 67718 3.26 FALSE 4380 8 Turkey 2043704 0 18351 0.9 FALSE 1834705 9 Italy 1964054 0 69214 3.52 FALSE 1281258 10 Spain 1817448 0 48926 2.69 FALSE 196958 11 Argentina 1541285 0 41813 2.71 FALSE 1368346 12 Germany 1531998 0 26655 1.74 FALSE 1129280
install.packages("ggplot2")
Source: Holtz, 2020
Source: Kanevsky, 2020
Source: Kanevsky, 2020
Source: Kanevsky, 2020
Source: Kanevsky, 2020
Source: Kanevsky, 2020
install.packages("magick")
EDUCBA. 2020. Plot Function In R. [online] Available at: https://www.educba.com/plot-function-in-r/.
Holtz, Y., 2020. Data Visualization With R And Ggplot2. [online] R-graph-gallery.com. Available at: https://www.r-graph-gallery.com/ggplot2-package.html.
Kanevsky, G., 2020. Facts About Coronavirus Disease 2019 (COVID-19) In 5 Charts Created With R And Ggplot2. [online] Novyden.blogspot.com. Available at: https://novyden.blogspot.com/2020/03/facts-about-coronavirus-disease-2019.html.
Kumar, P., 2020. Understanding Plot() Function In R. [online] JournalDev. Available at: https://www.journaldev.com/36083/plot-function-in-r.
Pedersen, T., 2020. Ggplot2 Package. [online] Rdocumentation.org. Available at: https://www.rdocumentation.org/packages/ggplot2/versions/3.3.2.
Qian, X., 2020. Visualize The Pandemic With R #COVID-19. [online] Medium. Available at: https://towardsdatascience.com/visualize-the-pandemic-with-r-covid-19-c3443de3b4e4.